<?php
/**
 *+------------------
 * Lflow
 *+------------------
 * Copyright (c) 2023~2030 gitee.com/liu_guan_qing All rights reserved.本版权不可删除，侵权必究
 *+------------------
 * Author: Mr.April(405784684@qq.com)
 *+------------------
 */
declare (strict_types=1);

namespace lflow\implement;

use lflow\Completion;
use lflow\entity\HistoryOrder;
use lflow\entity\HistoryTask;
use lflow\Logger;

/**
 * 默认任务实例完成时触发的动作
 *
 * @author Mr.April
 * @since  1.0
 */
class GeneralCompletion implements Completion
{

    public function complete(HistoryOrder|HistoryTask $history): void
    {
        //完成任务
        if ($history instanceof HistoryTask) {
            $info = $history->getId() . $history->getOperator();
            Logger:: info("The task[{}] has been user[{}] has completed" . json_encode($info));
        }
        //完成实例
        if ($history instanceof HistoryOrder) {
            Logger:: info("The task[{}] has been user[{}] has completed" . json_encode($history->getId()));
        }
    }
}